<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'register.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
    <style type="text/css">
    table{position:absolute;left:340px;top:90px;width:400px;}
    .input{width:180px;height:25px;}
    </style>
  </head>
  
  <body background="img/4561.jpg">
    <form name="form1" action="" method="post" enctype="multipart/form-data">
      <table border="2" bordercolor="pink">
        <tr>
          <td align="center" colspan="2">
            <c:if test="${null!=msg }">
              <font color="red">${msg }</font>
            </c:if>
          </td>
        </tr>
        <tr>
          <td align="center" colspan="2">
              <font size="5" color="red">用户注册</font> 
          </td>
        </tr>
        <tr>
          <td align="center">
              <font color="red">注册名</font>
          </td>
          <td align="center">
              <input type="text" class="input" name="registerName" value=""/>
          </td>
        </tr>
        <tr>
          <td align="center">
              <font color="red">密码</font>
          </td>
          <td align="center">
              <input type="password" class="input" name="registerPass" value=""/>
          </td>
        </tr>
        <tr>
          <td align="center">
              <font color="red">授权码</font>
          </td>
          <td align="center">
              <input type="text" class="input" name="powerCode" value=""/>
          </td>
        </tr>
        <tr>
          <td align="center">
              <font color="red"> 授权密码</font>
          </td>
          <td align="center">
              <input type="text" class="input" name="powerPass" value=""/>
          </td>
        </tr>
        <tr>
    	  <td align="center">
    	      <font color="red">上传<br/></br>头像</font>
    	  </td>
    	  <td align="center">
    		<img alt="我的靓照" src="" id="img" width="180" height="200" ><br/>
    		<input type="file" id="upfile" class="input" name="upFile" value="" onchange="chang();">
    	  </td>
    	</tr>
        <tr>
          <td align="center" colspan="2">
              <input type="button" name="but1" value="提交" onclick="chek();"/>
              <input type="button" name="but2" value="返回" onclick="window.location='login.jsp'"/>
          </td>
        </tr>
      </table>
    </form>
  </body>
  <script type="text/javascript">
  function $(id){
	  return document.getElementById(id);
  }
  function chek(){
	  var registerName=$("registerName").value;
	  var registerPass=$("registerPass").value;
	  var powerCode=$("powerCode").value;
	  var powerPass=$("powerPass").value;
	  var filename=$("upfile").value;
	  var form=$("form1");
	  if(""==registerName||""==registerPass||""==powerCode||""==powerPass){
		  alert("请将信息填写完整!");
	  }else{
		  if(""==filename){
			  alert("请上传头像!");
		  }else{
		      form.action="doRegisterServlet";
		      form.submit();
		  }
	  }
  }
  function chang(){
		var img = $("img");
		var file = $("upfile");
		img.src = file.value;
		
	}
  </script>
</html>
